import torch
from torch import nn
from nlpx.model import TextCNN


if __name__ == '__main__':
	word_dim = 10
	batch_size = 4
	X = torch.randn(batch_size, 10, word_dim)
	num_classes = 2  # 假设二分类问题
	targets = torch.randint(0, num_classes, (batch_size,))

	model = TextCNN(word_dim, kernel_sizes=(2, 3, 4), cnn_channels=64, out_features=num_classes, num_hidden_layer=None,
					activation=nn.ReLU6(inplace=True), residual=True)

	# output = model(X)
	# print(output.shape, output)

	loss, output = model(X, targets)
	print(type(loss), loss, output)

